import React from 'react';
import { Table} from 'antd';
import type { ColumnsType } from 'antd/es/table';

// 接口太多 需要提到公共的interface /types 目录中
interface IColumnsProps {
    key: string,
    chain_id: number;
    // hospital_id: number;
    chain_name: string;
    // chain_no: number;
    // is_use: boolean;
    // privice: number;
    // city: number;
    // disct: number;
    address: string;
    // thumb: string;
    // type: number;
    // attr: number;
    // tel: string;
    // coordinate: string;
    // addtime: number;
    // hospital_name: string;
}
interface ITableProps {
    columns?: any[],
    data: IColumnsProps[],
    getVisitorList: () => void
}
// columns 中的key可以删除，注意dataIndex必须指定
const defcolumns: ColumnsType<IColumnsProps> = [
    {
        title: '机构ID',
        dataIndex: 'chain_id',
    },
    {
        title: '机构名称',
        dataIndex: 'chain_name',
        render: (text) => <a>{text}</a>,
    },

    {
        title: '所在城市',
        dataIndex: 'address',
    },

    // {
    //     title: '操作',
    //     key: 'action',
    //     render: (_, record) => (
    //         <Space size="middle">
    //             <button>修改 {record}</button>
    //         </Space>
    //     ),
    // },
];
// 默认值 给每行绑定一个唯一的key
const TableBase: React.FC<ITableProps> = ({ columns=defcolumns, data }) => <Table rowKey={(record) => record.chain_id} columns={columns} dataSource={data} />;

export default TableBase;